<?php 
// Nguyen Binh
// suongmumc@gmail.com
// update 10/2010

defined( '_VALID_NVB' ) or die( 'Direct Access to this location is not allowed.' );
$tpl=new TemplatePower("skin/sk_uploadphoto.htm");
$tpl->prepare();

		require ("../lib/upload.php");
		require ("../lib/imaging.php");
		$in_name=compile_post('name');
		
		$a=array();
		$a['name']			=$in_name;
		$a['thu_tu']		=Auto_complate_order(intval($_REQUEST['id_catab']));
		//$a['active']		=intval(compile_post("active"));
		$a['active']		=1;
		//$a[$id_category]	=intval(compile_post("parentid"));
		//$a['intro']			=$_POST['intro'];
		$a['id_catab']		=intval($_REQUEST['id_catab']);
		$a['ngay_dang']		=time()+$CONFIG['time_offset'];
		$a['id_user']=$my['id'];
		
			
			$dich=$CONFIG['root_path'].$CONFIG['upload_image_path']."album/";
			
			$image=uploadimage("myfile",'yes',$dich);
			
			$a['image']			=$image['image'];
			$a['normal_image']	=$image['normal_image'];
			$a['small_image']	=$image['small_image'];
		
		$b=$DB->compile_db_insert_string($a);
	$sql="INSERT INTO album (".$b['FIELD_NAMES'].") VALUES (".$b['FIELD_VALUES'].")";
	$DB->query($sql);
		// xu ly anh
		
	
	
	
$tpl->printToScreen();	
function Auto_complate_order($idc){
	global $DB;
	$tt=0;
	$idc=intval($idc);
	$sql="SELECT thu_tu FROM album WHERE id_catab=$idc ORDER BY thu_tu DESC LIMIT 0,1";
	$db=$DB->query($sql);
	if($rs=mysql_fetch_array($db)){
		$tt=$rs['thu_tu']+1;
	}
	return $tt;
}


?>